﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ePlanet.ArchiveMange.Services;
using DreamBuilder.Common;
using ePlanet.ArchiveMange.DataAccess;
using System.Data;
using ePlanet.ArchiveMange.Models;

namespace ePlanet.ArchiveMange.Business
{
    public class BUSPageFile : BusinessBase,IPageFileService
    {
        PageFileDAL dal = new PageFileDAL();
        ArchiveCommon commonDal = new ArchiveCommon();

        #region IArchiveBase 成员

        bool IArchiveBase.SaveData(DataSet ds)
        {
            return commonDal.SaveData(ds);
        }

        
        public DataSet GetAttach(string ObjectID, string DBHelperString)
        {
            return commonDal.GetAttach(ObjectID, DBHelperString);
        }

        public bool SaveAttach(DataTable dt_Attach, string objectTableName, string objectID, string DBHelperString)
        {
            return commonDal.SaveAttach(dt_Attach, objectTableName, objectID, DBHelperString);
        }

        #endregion

        #region IPageFileService 成员

        public ArchiveMangeModal.PAGEFILEDataTable GetAllDocumenArchivetData()
        {
            return dal.GetAllDocumenArchivetData();
        }

        /// <summary>
        /// 根据卷ID获取卷内件的数据
        /// </summary>
        /// <param name="archiveId">卷ID</param>
        /// <returns></returns>
        public ArchiveMangeModal.PAGEFILEDataTable GetPgeFileByArchiveID(string archiveId)
        {
            return dal.GetPgeFileByArchiveID(archiveId);
        }

        public ArchiveMangeModal.PAGEFILEDataTable GetAllDocumenArchivetDataById(string DATAID)
        {
            return dal.GetAllDocumenArchivetDataById(DATAID);
        }

        public DataTable GetPageFileByFileIdList(IList<string> fileIdList)
        {
            return dal.GetPageFileByFileIdList(fileIdList);
        }

        /// <summary>
        /// 取卷内件载体信息
        /// </summary>
        /// <param name="fileIdList"></param>
        /// <returns></returns>
        public DataTable GetPageFileCarrierTypeByFileIdList(IList<string> fileIdList)
        {
            return dal.GetPageFileCarrierTypeByFileIdList(fileIdList);
        }

        public DataTable GetPageFileByArchiveIdListAndType(IList<string> fileIdList, int archiveTypeId)
        {
            return dal.GetPageFileByArchiveIdListAndType(fileIdList, archiveTypeId);
        }

        /// <summary>
        /// 获取某种类型档案的活动件
        /// </summary>
        /// <param name="archiveType"></param>
        /// <returns></returns>
        public DataTable GetPageFileByArchiveType(string archiveType)
        {
            return commonDal.GetPageFileByArchiveType(archiveType);
        }
        /// <summary>
        /// 改变卷内件的序号
        /// </summary>
        /// <param name="pageFileId"></param>
        /// <param name="order"></param>
        public void ChangePageFileOrder(string pageFileId, int order)
        {
            dal.ChangePageFileOrder(pageFileId, order);
        }

        /// <summary>
        /// 将两个卷内件的序号互换
        /// </summary>
        /// <param name="DATAID"></param>
        /// <param name="DataID2"></param>
        public void MovePageFileOrder(string DATAID, string DataID2)
        {
            dal.MovePageFileOrder(DATAID, DataID2);
        }

        /// <summary>
        /// 获取该卷内件最大的ID
        /// </summary>
        /// <param name="ArchiveId"></param>
        /// <param name="order"></param>
        public int GetPageFileMaxOrder(string ArchiveId)
        {
            return dal.GetPageFileMaxOrder(ArchiveId);
        }

        /// <summary>
        /// 根据主键删除数据
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool DeleteData(string key)
        {
            return dal.DeleteData(key);
        }

        /// <summary>
        /// 从卷内件中移除件
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool RemoveData(string key)
        {
            return dal.RemoveData(key);
        }

        public void SetPageFileArchiveNum(string archiveId, string archiveNum)
        {
            dal.SetPageFileArchiveNum(archiveId, archiveNum);
        }

        #endregion



        public bool IsSameSecret(List<Guid> dataIDList)
        {
            return dal.IsSameSecret(dataIDList);
        }

        public byte[] GetAttachContentByID(string dataID, string DBHelperString)
        {
            return this.commonDal.GetAttachContentByID(dataID, DBHelperString);
        }

    }
}
